/**
 * 功能: vue项目构建配置
 * http://192.168.102.233:83/#/doc/guid/vue-cli
 */

const CompressionPlugin = require('compression-webpack-plugin')

const libName = require('./package.json').name
process.env.VUE_APP_LIB_NAME = 'tw-lib-' + libName

const alias = require('./vue-config/alias')

module.exports = {
  publicPath: '/',
  outputDir: './libraries',
  productionSourceMap: false,

  configureWebpack: config => {
    config.entry = `./src/${process.env.VUE_APP_LIB_NAME}/main.js`
    Object.assign(config.resolve.alias, alias)

    if (process.env.NODE_ENV === 'production') {
      return {
        plugins: [new CompressionPlugin({
          test: /\.js$|\.css/,
          exclude: /app-config.js/,
          threshold: 1024,
          deleteOriginalAssets: false
        })]
      }
    }
  },

  chainWebpack: config => {
    config.module.rules.delete('eslint')
  }
}
